unit uProdProc;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, uPai_new, Menus, DBXpress, DB, StdCtrls, Buttons, ExtCtrls,
  MMJPanel, FMTBcd, DBClient, Provider, SqlExpr, Grids, DBGrids,
  JvExDBGrids, JvDBGrid;

type
  TfProdProc = class(TfPai_new)
    BitBtn1: TBitBtn;
    edProd: TEdit;
    Label2: TLabel;
    gridProd: TJvDBGrid;
    sdsProc: TSQLDataSet;
    dspProc: TDataSetProvider;
    cdsProc: TClientDataSet;
    dsProc: TDataSource;
    sdsProcPRO_CODPRO: TStringField;
    sdsProcPRO_DESCRI: TStringField;
    cdsProcPRO_CODPRO: TStringField;
    cdsProcPRO_DESCRI: TStringField;
    sdsProcPRO_VOLEMB: TFMTBCDField;
    cdsProcPRO_VOLEMB: TFMTBCDField;
    procedure BitBtn1Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure gridProdCellClick(Column: TColumn);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    codPro, ProDescri : String;
    { Public declarations }
  end;

var
  fProdProc: TfProdProc;

implementation

uses udm;

{$R *.dfm}

procedure TfProdProc.BitBtn1Click(Sender: TObject);
begin
  //inherited;
  if (cdsProc.Active) then
    cdsProc.Close;
  cdsProc.Params.ParamByName('PROD').AsString := edProd.Text + '%';
  cdsProc.Open;
end;

procedure TfProdProc.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  //inherited;
  if (cdsProc.Active) then
  begin
    codPro    := cdsProc.Fields[0].asString;
    ProDescri := cdsProc.Fields[1].asString;
  end;
end;

procedure TfProdProc.gridProdCellClick(Column: TColumn);
begin
  inherited;
  if (cdsProc.Active) then
  begin
    codPro    := cdsProc.Fields[0].asString;
    ProDescri := cdsProc.Fields[1].asString;
  end;
end;

procedure TfProdProc.FormShow(Sender: TObject);
begin
  inherited;
  codPro    := '';
  ProDescri := '';
end;

end.
